package com.teamwork.demo.controller;

import cn.hutool.core.util.ObjectUtil;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.teamwork.demo.entity.Application;
import com.teamwork.demo.entity.Group;
import com.teamwork.demo.entity.Class;
import com.teamwork.demo.entity.Stu;
import com.teamwork.demo.service.StuService;

import java.util.ArrayList;
import java.util.List;
@Controller
public class StuController {
    @Autowired
    public StuService stuService;
    @GetMapping("/findallstu")
    @ResponseBody
    public Page<Stu> findAll(Stu stu , Integer page, Integer limit) {
        return stuService.findAll(stu ,page, limit);
    }

   @GetMapping("/savestu")
   @ResponseBody
    public Stu save (Stu stu) {
        return stuService.save(stu);
    }

    @GetMapping("/updatestu")
    @ResponseBody
    public Stu update(Stu stu){
        return stuService.save(stu);
    }

    @GetMapping("/findallapplication")
    @ResponseBody
    public Page<Application> findAll(Application application, int page, int limit){
        return stuService.findAll(application ,page, limit);
    }

    @GetMapping("/saveapplication")
    @ResponseBody
    public Application save(Application application) {
        return stuService.save(application);
    }

    @GetMapping("/updateapplication")
    @ResponseBody
    public Application update(Application application){
        return stuService.update(application);
    }

    @GetMapping("findallgroup")
    @ResponseBody
    public Page<Group> findAll(Group group, int page, int limit ){
        return stuService.findAll(group ,page, limit);
    }

    @GetMapping("/findallclass")
    @ResponseBody
    public Page<Class> findAll(Class sclass, int page, int limit ){
        return stuService.findAll(sclass ,page, limit);
}




}


